//============================================================================
// Name        : Hal.cpp
// Author      : Cristian Gonzalo Gary Bufadel
// Version     :
// Copyright   : 
// Description :
//============================================================================

using namespace std;

#include "Sched.h"
#include <Logger.h>
#include "Database.h"

#include "MyListener1.cpp"
#include "MySubject.cpp"


#if defined(__DATE__) && defined(__TIME__)
static const char HAL_BUILT[] = __DATE__ " " __TIME__;
#else
static const char HAL_BUILT[] = "Unknown";
#endif

#define OS "Linux"

#define __HAL__            0
#define __HAL_MINOR__      01
#define __HAL_PATCHLEVEL__ 0
#define CC "gcc"

#define HAL_VERSION (__HAL__ * 10000 \
                                __HAL_MINOR__ * 100 \
                                __HAL_PATCHLEVEL__)
#define VERSION "0.01.0"

#define RUN 1
#define NO_RUN 0

int Logger::init_time = time(NULL);

void hal_version(void) {
	printf("HAL %i.%i.%i\n", __HAL__, __HAL_MINOR__, __HAL_PATCHLEVEL__);
	printf("Built : %s (%s %i.%i.%i)\n", HAL_BUILT, CC, __GNUC__,
			__GNUC_MINOR__, __GNUC_PATCHLEVEL__);
	printf("Home  : http://www.seginus.cl\n");
	fflush(stdout);
}

int main(void) {

	hal_version();

	 MyListener1* listener1 = new MyListener1;
	 MySubject subject;


	 int h1 = subject.int_event.attach(listener1, &MyListener1::update_int);


	 subject.submit_int(34);

//	Logger* logger = new Logger();

//	Sched* sched = new Sched();

	//sched->runWorkers();

//	int j = 1;

//	while (RUN) {
//		//sleep(2);
//	//	sched->createWorkerAndRun("Worker nuevo ", "nuevo ");
//		//sched->printSize();
//	}

//	for (j =1; j< 10; j++){
//		sched->createWorkerAndRun("nuevo ", " nuevo");
//		#ifdef TRACE
//			HAL_TRACE(logger, "creado hilo numero : %i", j);
//		#endif
//	}
//
//
//	sleep(200);
//
//	delete logger;
//	delete sched;

}
